
e_sites_old=e_sites(1:17,:);
c_sites_old=c_sites(18:31,:);

e_sites_new=e_sites;

e_sites=[e_sites_new; e_sites_old];
c_sites=c_sites_old;


e_sites=e_sites/nanmedian(nanmedian(e_sites(:,1:2)));
c_sites=c_sites/nanmedian(nanmedian(c_sites(:,1:2)));

% e_sites=e_sites./(nanmedian(e_sites(:,1:2),2)*ones(1,size(e_sites,2)));
% c_sites=c_sites./(nanmedian(c_sites(:,1:2),2)*ones(1,size(c_sites,2)));


m_e_sites=nanmedian(e_sites);
s_e_sites=nanstd(e_sites)/sqrt(size(e_sites,1));
m_c_sites=nanmedian(c_sites);
s_c_sites=nanstd(c_sites)/sqrt(size(c_sites,1));


figure;
clf
hold on
plot(tpoints(1:6),m_e_sites(1:6),'ok','linewidth',2)
plot(tpoints(1:2),m_e_sites(1:2),'k','linewidth',2)
plot(tpoints(3:6),m_e_sites(3:6),'k','linewidth',2)
for ind=1:6
    plot([1 1]*tpoints(ind),[-1 1]*s_e_sites(ind)+m_e_sites(ind),'k')
end

plot(tpoints(1:6),m_c_sites(1:6),'or','linewidth',2)
plot(tpoints(1:2),m_c_sites(1:2),'r','linewidth',2)
plot(tpoints(3:6),m_c_sites(3:6),'r','linewidth',2)
for ind=1:6
    plot([1 1]*tpoints(ind),[-1 1]*s_c_sites(ind)+m_c_sites(ind),'r')
end
title(title_str,'fontweight','bold');
xlabel('Mean over regions')


n_e_sites=e_sites./(nanmean(e_sites(:,1:2)')'*ones(1,6));


gc5_ind=[1:24];
gc3_ind=[25:41];

l5_ind=[28 29 33 34 37 38 41];
l2_ind=setdiff([1:41],l5_ind);

figure;
clf
hold on
plot(tpoints(1:6),n_e_sites(gc5_ind,1:6),'ok','linewidth',2)
plot(tpoints(1:2),n_e_sites(gc5_ind,1:2),'k','linewidth',2)
plot(tpoints(3:6),n_e_sites(gc5_ind,3:6),'k','linewidth',2)

plot(tpoints(1:6),n_e_sites(gc3_ind,1:6),'or','linewidth',2)
plot(tpoints(1:2),n_e_sites(gc3_ind,1:2),'r','linewidth',2)
plot(tpoints(3:6),n_e_sites(gc3_ind,3:6),'r','linewidth',2)


figure;
clf
hold on
plot(tpoints(1:6),n_e_sites(l2_ind,1:6),'og','linewidth',2)
plot(tpoints(1:2),n_e_sites(l2_ind,1:2),'g','linewidth',2)
plot(tpoints(3:6),n_e_sites(l2_ind,3:6),'g','linewidth',2)

plot(tpoints(1:6),n_e_sites(l5_ind,1:6),'om','linewidth',2)
plot(tpoints(1:2),n_e_sites(l5_ind,1:2),'m','linewidth',2)
plot(tpoints(3:6),n_e_sites(l5_ind,3:6),'m','linewidth',2)








%%%%%%%%%%%%% RUNNING %%%%%%%%%%%%%%%%%%%%

fract_running_old=fract_running;
fract_running_new=fract_running;

fract_running_exp=[fract_running_old(1:17,1:6); fract_running_new(:,1:6)];
fract_running_ctr=fract_running_old(18:31,1:6);

figure;hold on
plot(tpoints(1:6),nanmean(fract_running_exp(:,1:6)),'ok','linewidth',2)
plot(tpoints(1:2),nanmean(fract_running_exp(:,1:2)),'k','linewidth',2)
plot(tpoints(3:6),nanmean(fract_running_exp(:,3:6)),'k','linewidth',2)

for ind=1:6
    plot([1 1]*tpoints(ind),[-1 1]*nanstd(fract_running_exp(:,ind))/sqrt(sum(~isnan(fract_running_exp(:,ind))))+nanmean(fract_running_exp(:,ind)),'k','linewidth',2);
end


plot(tpoints(1:6),nanmean(fract_running_ctr(:,1:6)),'or','linewidth',2)
plot(tpoints(1:2),nanmean(fract_running_ctr(:,1:2)),'r','linewidth',2)
plot(tpoints(3:6),nanmean(fract_running_ctr(:,3:6)),'r','linewidth',2)


for ind=1:6
    plot([1 1]*tpoints(ind),[-1 1]*nanstd(fract_running_ctr(:,ind))/sqrt(sum(~isnan(fract_running_ctr(:,ind))))+nanmean(fract_running_ctr(:,ind)),'r','linewidth',2);
end

